package book;

import java.util.HashMap;
import java.util.Scanner;

public class Person {
    private String name;
    public Person(){}
    public Person(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

//    public Book buyBook(Book[] book){
//        Book book1 = null;
//        System.out.println("请输入购书标号：");
//        Scanner sc = new Scanner(System.in);
//        int id = sc.nextInt();
//        for(int i = 0;i<book.length;i++){
//            if(book[i].getId()==id){
//                book1 = book[i];
//                break;
//            }
//        }
//        return book1;
//    }
    public HashMap<Book,Integer> buyBooks(Book [] books){
        HashMap<Book,Integer> bookList = new HashMap<>();
        while (true){
            System.out.println("请输入购书标号，按零退出");
            Scanner sc = new Scanner(System.in);
            int id = sc.nextInt();
            if(id==0){
                break;
            }else{
                System.out.println("请输入购买数量：");
                int number = sc.nextInt();
                for(int i = 0;i< books.length;i++){
                    if(books[i].getId()==id){
                        bookList.put(books[i],number);
                        break;
                    }
                }
            }
        }
        return bookList;

    }
}
